CROSS_COMPILE = arm-linux-gnueabihf-

AS		= $(CROSS_COMPILE)as
LD		= $(CROSS_COMPILE)ld
CC		= $(CROSS_COMPILE)gcc
CPP		= $(CC) -E
AR		= $(CROSS_COMPILE)ar
NM		= $(CROSS_COMPILE)nm

STRIP		= $(CROSS_COMPILE)strip
OBJCOPY		= $(CROSS_COMPILE)objcopy
OBJDUMP		= $(CROSS_COMPILE)objdump

CFLAGS = -g -Wall -marm -mabi=aapcs-linux -mno-thumb-interwork -Wa,-march=armv7-a -nostdlib -fno-builtin -c -O2 -I$(shell pwd)/include -I$(shell pwd)/arch/arm/include
LDFLAGS = -lgcc -L /home/zhangxu/study/imx6ull/cross_compiler/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/lib/gcc/arm-linux-gnueabihf/4.9.4
OBJCOPYFLAGS =


BUILTIN += ../lib/libc.a \

cat.bin: cat.o $(BUILTIN)
	$(LD) -T cat.lds $^ $(LDFLAGS) -o cat.elf
	$(STRIP) --strip-all cat.elf
	$(OBJCOPY) $(OBJCOPYFLAGS) -O binary cat.elf cat.bin
	$(OBJDUMP) -D -m arm cat.elf > cat.dis

%.o:%.c
	$(CC) $(CFLAGS) -c $< -o $@

%.o:%.S
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	rm -rf *.o *.elf *.dis *.bin
